using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using PowerSearch.AppServices;
using PowerSearch.Core;
using System.Text;
using PowerSearch.ICS.UI;

namespace PowerSearch.ICS
{
	[Activity (Label = "Power Search", MainLauncher = true)]
	public class MainActivity : Activity
	{
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			// Set our view from the "main" layout resource
			SetContentView (Resource.Layout.Main);

			var gridView = FindViewById<GridView> (Resource.Id.gridview);
			gridView.Adapter = new ImageAdapter (this);

			gridView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
				var provider = (gridView.GetItemAtPosition(e.Position) as SearchResult).Result;

				var resultIntent = new Intent(this, typeof(ResultActivity));
				resultIntent.PutExtra("Provider", provider);
				StartActivity(resultIntent);
			};
		}
	}
}
